package cn.hchaojie.cts;


import java.util.Random;

import javafx.scene.paint.Color;

public class BrickFactory {
	private static final Random RANDOM = new Random();
	
	private static final int[][] I = { 
			{ 0, 0, 0, 0 }, 
			{ 1, 1, 1, 1 }, 
			{ 0, 0, 0, 0 }, 
			{ 0, 0, 0, 0 } 
	};

	private static final int[][] J = { 
			{ 1, 0, 0 }, 
			{ 1, 1, 1 }, 
			{ 0, 0, 0 },
	};
	
	private static final int[][] L = { 
			{ 0, 0, 1 }, 
			{ 1, 1, 1 }, 
			{ 0, 0, 0 } 
	};

	private static final int[][] O = { 
			{ 1, 1 }, 
			{ 1, 1 }
	};

	private static final int[][] S = { 
			{ 0, 1, 1 }, 
			{ 1, 1, 0 }, 
			{ 0, 0, 0 }
	};
	
	private static final int[][] T = { 
			{ 0, 1, 0 }, 
			{ 1, 1, 1 }, 
			{ 0, 0, 0 } 
	};

	private static final int[][] Z = { 
			{ 1, 1, 0 }, 
			{ 0, 1, 1 }, 
			{ 0, 0, 0 } 
	};
	
	private static final int[][][] BRICKS = {
			I, J, L, O, S, T, Z
	};
	
	private static final Color[] COLORS = {
		Color.CYAN, Color.BLUE, Color.ORANGE, Color.GREENYELLOW, Color.PURPLE, Color.ORANGERED, Color.BROWN
	};

    public static Brick random(double size) {
    	int idx = RANDOM.nextInt(7);

        return new Brick(BRICKS[idx], COLORS[idx], size);
    }
}
